import request from '@/config/axios'

// 每日账户结存 VO
export interface BalanceVO {
  id: number // 主键
  reportDate: Date // 报表日期
  yesterdayBalance: number // 昨日账户结存
  todayBalance: number // 今日账户结存
}

// 每日账户结存 API
export const BalanceApi = {
  // 查询每日账户结存分页
  getBalancePage: async (params: any) => {
    return await request.get({ url: `/erp/balance/page`, params })
  },

  // 查询每日账户结存详情
  getBalance: async (id: number) => {
    return await request.get({ url: `/erp/balance/get?id=` + id })
  },

  // 新增每日账户结存
  createBalance: async (data: BalanceVO) => {
    return await request.post({ url: `/erp/balance/create`, data })
  },

  // 修改每日账户结存
  updateBalance: async (data: BalanceVO) => {
    return await request.put({ url: `/erp/balance/update`, data })
  },

  // 删除每日账户结存
  deleteBalance: async (id: number) => {
    return await request.delete({ url: `/erp/balance/delete?id=` + id })
  },

  // 导出每日账户结存 Excel
  exportBalance: async (params) => {
    return await request.download({ url: `/erp/balance/export-excel`, params })
  },

// ==================== 子表（每日盈亏） ====================

  // 获得每日盈亏分页
  getProfitLossDaySlavePage: async (params) => {
    return await request.get({ url: `/erp/balance/profit-loss-day-slave/page`, params })
  },
  // 新增每日盈亏
  createProfitLossDaySlave: async (data) => {
    return await request.post({ url: `/erp/balance/profit-loss-day-slave/create`, data })
  },

  // 修改每日盈亏
  updateProfitLossDaySlave: async (data) => {
    return await request.put({ url: `/erp/balance/profit-loss-day-slave/update`, data })
  },

  // 删除每日盈亏
  deleteProfitLossDaySlave: async (id: number) => {
    return await request.delete({ url: `/erp/balance/profit-loss-day-slave/delete?id=` + id })
  },

  // 获得每日盈亏
  getProfitLossDaySlave: async (id: number) => {
    return await request.get({ url: `/erp/balance/profit-loss-day-slave/get?id=` + id })
  },
}